<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>手机商城</title>
	<link rel="stylesheet" href="../../static/shopping/css/style.css">
	<script src="../../static/shopping/js/jquery-1.8.3.min.js"></script>
      <script src="../../static/shopping/js/banner.js"></script>
</head>
<body>
	<div class="top"></div>
	<div class="top1">
        <a href="${pageContext.request.contextPath}/toIndex">首页</a>
        <a href="https://consumer.huawei.com/cn/">华为官网</a>
        <a href="https://www.honor.cn/">荣耀官网</a>
        <a href="https://club.huawei.com/">花粉俱乐部</a>
        <a href="#">V码（优购码）</a>
        <a href="https://company.vmall.com/">企业购</a>
        <a href="#">Select Region</a>
        <a href="#">更多精彩</a>
        <span>
        <c:if test="${sessionScope.user==null}">
             <a href="${pageContext.request.contextPath}/toLogin">你好,请登录</a>
             <a href="${pageContext.request.contextPath}/toRegister">注册</a>
        </c:if>

        <c:if test="${sessionScope.user!=null}">
            <a href="">欢迎回来! ${sessionScope.users.account}</a>
            <a href="${pageContext.request.contextPath}/toLogin">退出</a>
            <a href="#">我的订单</a>
        </c:if>
                     <a href="#">客户服务</a>
                     <a href="#">网站导航</a>
                     <a href="#">手机版</a>

        <c:if test="${sessionScope.user!=null}">
            <a href="${pageContext.request.contextPath}/toCart_list">购物车</a>
        </c:if>

<%--        <c:if test="${sessionScope.user==null}">--%>
<%--            <a href="#">购物车</a>--%>
<%--        </c:if>--%>

           </span>
	</div>
	<div class="nav w">
		<ul>
			<li><img src="../../static/shopping/images/logo.png" alt=""><img src="../../static/shopping/images/tb1.png" alt=""><img src="../../static/shopping/images/tb2.png" alt=""></li>
			<li>
          <a href="${pageContext.request.contextPath}/toIndex">首页</a>
          <a href="${pageContext.request.contextPath}/toShop_list">商品展示页</a>
          <a href="${pageContext.request.contextPath}/getShop_hot">商品热销推荐页</a>
<%--          <a href="${pageContext.request.contextPath}/toCart_list">购物车页</a>--%>
<%--          <a href="${pageContext.request.contextPath}/toRegister">注册页</a>--%>
<%--          <a href="${pageContext.request.contextPath}/toLogin">登录页</a>--%>
      </li>
		</ul>
	</div>
  <hr>
<div class="gg3 w"><img src="../../static/shopping/images/gg3.jpg" alt=""></div>
<div class="rx w">
    <h1>热销单品</h1>
    <div class="bao">
    <div class="left">
        <img src="../../static/shopping/images/left.png" alt="">
    </div>
    <div class="right">
     <ul>
        <c:forEach items="${phones}" var="phone">
            <li>
                <img src="../../static/shopping/images/${phone.url}" alt=""><h4>${phone.name}</h4><p>12期</p><span>¥${phone.price}</span>
                <a href="javascript:;" onclick="add_card(${phone.id})" style="width: 80px;height: 30px;line-height: 30px; text-align: center; background: red;color:#fff;display: block;border-bottom-left-radius: 10px;margin-top: 1px;">添加购物车</a>
            </li>
        </c:forEach>
    </ul>
    </div>
 </div>
</div>


<%--<div class="rx w">--%>
<%--    <h1>精品推荐</h1>--%>
<%--    <div class="bao">--%>
<%--    <div class="left"><img src="../../static/shopping/images/left.png" alt=""></div>--%>
<%--    <div class="right">--%>
<%--     <ul>--%>
<%--         <li><img src="../../static/shopping/images/s19.png" alt=""><h4>HUAWEI nova7 Pro 5G</h4><p>多款可选</p><span>¥3699</span>--%>
<%--             <a href="javascript:;" onclick="add_card(0)" style="width: 80px;height: 30px;line-height: 30px; text-align: center; background: red;color:#fff;display: block;border-bottom-left-radius: 10px;margin-top: 1px;">添加购物车</a>--%>
<%--         </li>--%>
<%--    </ul>--%>
<%--    </div>--%>
<%-- </div>--%>
<%--</div>--%>
    <script>
    function add_card(id) {
        var data = {pid:id}
        $.ajax({
            url: "/add_card",
            data: data,
            type: "POST",
            success: function (result) {
                var res = JSON.stringify(result)
                if(res == 1){
                    alert('添加成功')
                }else if(res == 2){
                    alert('已经添加')
                }
            }
        })
    }
</script>
<div class="kb"></div>
<div class="footer">
    <p>制作团队：晚睡协会</p>
</div>
</body>
</html>